package school.emm;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity extends Activity {
	EditText nickname;
	CheckBox gps, rememberMe;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.login);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);  
		nickname = (EditText) findViewById(R.id.nickname);
		rememberMe = (CheckBox) findViewById(R.id.remember);
		gps = (CheckBox) findViewById(R.id.GPS);
	}
	public void registerClient(View v) {
		if(!nickname.getText().toString().equalsIgnoreCase("")) {
			System.out.println("fisk");
			Intent data = new Intent();

			Bundle bundle = new Bundle();
			bundle.putString("nickname", nickname.getText().toString());
			if(gps.isChecked()){
				bundle.putBoolean("gps", true);
			} else {
				bundle.putBoolean("gps", false);
			}
			if(rememberMe.isChecked()){
				bundle.putBoolean("remember", true);
			}
			else {
				bundle.putBoolean("remember", false);
			}
			data.putExtras(bundle);

			setResult(RESULT_OK, data);
			finish();
		} else {
			Toast.makeText(this, "Enter nickname." , 2).show();
		}
	}
}
